<template>
	<view>
		<page-head headTitle="设置" :returnButton="true" @clickLeftReturn="clickLeftReturn"></page-head>
		<view class="m-t9">
			<view class="flex height-nav justify-between align-center border-botton p-l4 p-r2"> 
				<text class="fs-32">角色切换</text>
				<view class="input-goods flex align-center justify-content" @click="show">
					<text class="fs-2" style="">游客</text>
					<text class="iconfont icon-dibudaohanglan- set-size"></text>
				</view>
			</view>
			<view class="flex height-nav justify-between align-center border-botton p-l4 p-r2">
				<text class="fs-32">导游认证</text>
				<view class="input-goods flex align-center justify-content">
					<text class="fs-2" v-if="isGuide">已认证</text>
					<text class="fs-2" v-else>未认证</text>
					<text class="iconfont icon-dibudaohanglan- set-size"></text>
				</view>
			</view>
			<view class="flex height-nav justify-between align-center border-botton p-l4 p-r2">
				<text class="fs-32">商家认证</text>
				<view class="input-goods flex align-center justify-content">
					<text class="fs-2" v-if="isMerchant">已认证</text>
					<text class="fs-2" v-else>未认证</text>
					<text class="iconfont icon-dibudaohanglan- set-size"></text>
				</view>
			</view>
		</view>
		<view v-show="isShow">
			<view class="switch-bj fixed fixed-top" @click="hide"></view>
			<view class="fixed switch-content bg-white fs-32">
				<text class="flex justify-content align-center search-h border-botton" @tap="roles(2)">商家</text>
				<text class="flex justify-content align-center search-h border-botton" @tap="roles(1)">导游</text>
				<text class="flex justify-content align-center search-h">游客</text>
			</view>
		</view>
	</view>
</template>

<script>
import pageHead from '@/components/common/page-head.vue'
	export default {
		components:{
			pageHead
		},
		data() {
			return {
				isGuide:0,
				isMerchant:0,
				isShow:false
			}
		},
		onLoad() {
			this.getUserInfo();
		},
		methods: {
			//获取用户信息
			getUserInfo(){
				this.$myRequest({
					method:'POST',
					url:'/api/user/info'
				}).then(res=>{
					console.log(res);
					if(res.data.code == 1){
						var resultData = res.data.data;
						this.isGuide = resultData.user.is_guide;
						this.isMerchant = resultData.user.is_merchant;
					}
				})
			},
			clickLeftReturn(){
				uni.navigateBack({
				    delta: 1
				});
			},
			show(){
				this.isShow = true;
			},
			hide(){
				this.isShow = false;
			},
			roles(type){
				var that = this;
				if(type == 1){
					//导游首页
					if(that.isGuide){
						uni.reLaunch({
							url: '../../guide/index/index'
						})
					}else{
						uni.reLaunch({
							url: '../../guide/guide-unauthorized/guide-unauthorized'
						})
					}
					
				}else if(type == 2){
					//商家首页
					uni.reLaunch({
						url: '../../store/index/index'
					})
				}
			}
		}
	}
</script>

<style>
page{background-color: #FFFFFF;}
.switch-bj{background-color: #000000;width: 100%;height: 100%; opacity: .6;}
.switch-content{left: 30rpx;right: 30rpx;border-radius: 10rpx; bottom: 30rpx; z-index: 4;}
.switch-content text{width: 100%; text-align: center;}
</style>
